<script type="text/javascript">
	$(function() {
	    $.fn.dataGridOptions.formSubFun("#form",'/modules/user/vip/addVipLevel.html',"添加成功！","添加失败！");
	});


/*输入框限制:只能输入数字*/
$('input[onlynumber="true"]').keypress(function(e) {
    // 需要排除在firefox下某些按键不起作用的异常
    if(e.which && e.which != 8 && !(e.which >= 48 && e.which <= 57)) {
       return false;
    }
})
/*输入框限制:只能输入数字和小数点*/
$('input[numberpoint="true"]').bind({
    keypress: function(e) {
        // 需要排除在firefox下某些按键不起作用的异常
        if(e.which && e.which != 8 && !(e.which >= 48 && e.which <= 57 || e.which == 46)) {
           return false;
        }

        // 如果输入了1个小数点，则不能输入第2个小数点
        if(e.which == 46 && this.value.match(/\./) && this.value.match(/\./).length >= 1) {
            return false;
        }
    },
    keyup: function(e) {
        // 限制小数点后面的位数
        if($(this).attr('decimal')) {
            // 根据decimal属性判断需要的小数位数
            var decimalLen = parseInt($(this).attr('decimal'));
            var pointIndex = this.value.indexOf('.');
            if(pointIndex !== -1 && this.value.substr(pointIndex).length > decimalLen) {
                this.value = this.value.substring(0, pointIndex) + '.' + this.value.substr(pointIndex + 1, decimalLen);
            }
        }
    }
});


$('.borrowForm input').bind('keyup blur', function() {
    var boxval=this.value;  
        // 不能输入 类似00、01的数值
        if(boxval.match(/^0\d+/)){
            this.value = boxval.replace(/^0(\d+)/, '$1');
        }

        // 小数点前没有数字，自动在前面加上0
        if(boxval.match(/^0\./)){
            this.value = boxval.replace(/0\./, '');
        }

        // 如果输入的金额中没有小数点，只能输入到千万
        if(boxval.match(/\d{9}/)){
            this.value = boxval.substring(0, 8);
        }
})

</script>
<form id="form"  method="post">
<div class="borrowForm" style="border-top:none;padding-top:20px;">
    <ul>
    	<li><span>所需成长值：</span><input type="text" onlynumber="true" onafterpaste="this.value=this.value.replace(/\D/g,'')" name="growthValue" class="easyui-validatebox" data-options="required: true"/><font  color="red" size="4">*</font></li>
    	<li><span>成长封顶值：</span><input type="text" onlynumber="true"  onafterpaste="this.value=this.value.replace(/\D/g,'')" name="growthLimitValue" class="easyui-validatebox" data-options="required: true" maxlength="10" /><font  color="red" size="4">*</font></li>
    	<li><span>额外收益率：</span><input type="text" onafterpaste="this.value=this.value.replace(/\D/g,'')" numberpoint="true"  onblur="this.value=this.value.replace(/(\.\d{2})\d*$/,'\$1')"  name="extraRate" class="easyui-validatebox" data-options="required: true" maxlength="10"/><font  color="red" size="4">*</font></li>
    	<li>
    		<span>红包规则：</span>
	    	<div class="ipt">
				<select name="redEnvelopeRule" >
					<option value="0" selected>默认</option>
					<#list redEnvelopeList as item>
						<option value="${item.id!},${item.amount}">${item.name!}</option>
					</#list>
				</select>
			</div>
    	</li>
    </ul>
    </div>
</form>
